package com.moore.service.impl;

import com.moore.bean.EducationBackground;
import com.moore.bean.ProjectExperience;
import com.moore.bean.Resume;
import com.moore.bean.WorkExperience;
import com.moore.dto.ResponseData;
import com.moore.mapper.EduExperienceMapper;
import com.moore.mapper.ProExpMapper;
import com.moore.mapper.ResumeMapper;
import com.moore.mapper.WorkExperienceMapper;
import com.moore.service.ResumeService;
import com.moore.utils.TimeUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ResumeServiceImpl implements ResumeService {

    @Autowired
    private ResumeMapper resumeMapper;
    @Autowired
    private WorkExperienceMapper workExperienceMapper;
    @Autowired
    private EduExperienceMapper eduExperienceMapper;
    @Autowired
    private ProExpMapper proExpMapper;
    @Override
    public ResponseData getUserResume(Integer candidateId) {
        ResponseData responseData = new ResponseData();

        return responseData.returnObject(resumeMapper.getUserResume(candidateId));
    }

    @Override
    public ResponseData updateUserResume(Resume resume) {
        ResponseData responseData = new ResponseData();
        int count = resumeMapper.updateById(resume);
        return responseData.returnState(count);
    }

    @Override
    public ResponseData getUserWorkExp(Integer resumeId) {
        ResponseData responseData = new ResponseData();
        return responseData.returnList(workExperienceMapper.getUserWorkExp(resumeId),workExperienceMapper.getUserWorkExp(resumeId).size());
    }

    @Override
    public ResponseData addUserWorkExp(WorkExperience workExperience) {
        ResponseData responseData = new ResponseData();
        return responseData.returnState(workExperienceMapper.insert(workExperience));
    }

    @Override
    public ResponseData updateUserWorkExp(WorkExperience workExperience) {
        ResponseData responseData = new ResponseData();
        int count = workExperienceMapper.updateById(workExperience);
        return responseData.returnState(count);
    }

    @Override
    public ResponseData delUserWorkExp(Integer experienceId) {
        ResponseData responseData = new ResponseData();
        int count = workExperienceMapper.deleteById(experienceId);
        return responseData.returnState(count);
    }

    @Override
    public ResponseData getUserProExp(Integer resumeId) {
        ResponseData responseData = new ResponseData();
        return responseData.returnList(proExpMapper.getUserProExp(resumeId),proExpMapper.getUserProExp(resumeId).size());
    }

    @Override
    public ResponseData addUserProExp(ProjectExperience projectExperience) {
        ResponseData responseData = new ResponseData();
        int count = proExpMapper.insert(projectExperience);
        return responseData.returnState(count);
    }

    @Override
    public ResponseData updateUserProExp(ProjectExperience projectExperience) {
        ResponseData responseData = new ResponseData();
        int count = proExpMapper.updateById(projectExperience);
        return responseData.returnState(count);
    }

    @Override
    public ResponseData delUserExp(Integer id) {
        ResponseData responseData = new ResponseData();
        int count = proExpMapper.deleteById(id);
        return responseData.returnState(count);
    }

    @Override
    public ResponseData getUserEduExp(Integer resumeId) {
        ResponseData responseData = new ResponseData();
        return responseData.returnList(eduExperienceMapper.getUserEduExp(resumeId),eduExperienceMapper.getUserEduExp(resumeId).size());
    }

    @Override
    public ResponseData addUserEduExp(EducationBackground educationBackground) {
        ResponseData responseData = new ResponseData();
        int count = eduExperienceMapper.insert(educationBackground);
        return responseData.returnState(count);
    }

    @Override
    public ResponseData updateEduExp(EducationBackground educationBackground) {
        ResponseData responseData = new ResponseData();
        return responseData.returnState(eduExperienceMapper.updateById(educationBackground));
    }

    @Override
    public ResponseData delEduExp(Integer id) {
        ResponseData responseData = new ResponseData();
        return responseData.returnState(eduExperienceMapper.deleteById(id));
    }


}
